{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 1,
   "metadata": {},
   "outputs": [],
   "source": [
    "import numpy as np\n",
    "import pandas as pd\n",
    "import matplotlib.pyplot as plt\n",
    "import re\n",
    "import jieba\n",
    "from wordcloud import WordCloud"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>address</th>\n",
       "      <th>attribute</th>\n",
       "      <th>company</th>\n",
       "      <th>education</th>\n",
       "      <th>experience</th>\n",
       "      <th>general_situation</th>\n",
       "      <th>hiring_num</th>\n",
       "      <th>industry</th>\n",
       "      <th>members</th>\n",
       "      <th>position</th>\n",
       "      <th>record_date</th>\n",
       "      <th>salary</th>\n",
       "      <th>tag</th>\n",
       "      <th>time</th>\n",
       "      <th>title</th>\n",
       "      <th>welfare</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>重庆-江北区</td>\n",
       "      <td>上市公司</td>\n",
       "      <td>平安普惠企业管理有限公司重庆分公司</td>\n",
       "      <td>本科</td>\n",
       "      <td>1年经验</td>\n",
       "      <td>平安普惠业务集群（以下简称“平安普惠”）是中国平安保险（集团）股份有限公司联营公司旗下成员，...</td>\n",
       "      <td>招1人</td>\n",
       "      <td>金融/投资/证券,银行</td>\n",
       "      <td>1000-5000人</td>\n",
       "      <td>NaN</td>\n",
       "      <td>2021-05-29</td>\n",
       "      <td>6-8千/月</td>\n",
       "      <td>数据分析</td>\n",
       "      <td>05-28发布</td>\n",
       "      <td>1734LO-数据分析岗 (职位编号：1734LO)</td>\n",
       "      <td>五险一金,年底双薪,定期体检</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>上海-青浦区</td>\n",
       "      <td>民营公司</td>\n",
       "      <td>上海裕络物流有限公司</td>\n",
       "      <td>本科</td>\n",
       "      <td>3-4年经验</td>\n",
       "      <td>公司介绍,裕络物流于2008年创立上海，主要从事国内第三方物流业务包括行业物流解决方案、多式...</td>\n",
       "      <td>招1人</td>\n",
       "      <td>交通/运输/物流</td>\n",
       "      <td>150-500人</td>\n",
       "      <td>NaN</td>\n",
       "      <td>2021-05-29</td>\n",
       "      <td>0.8-1.5万/月</td>\n",
       "      <td>数据分析</td>\n",
       "      <td>05-29发布</td>\n",
       "      <td>运营质量及数据分析经理</td>\n",
       "      <td>五险一金,年终奖金,通讯补贴,餐饮补贴</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>广州-白云区</td>\n",
       "      <td>民营公司</td>\n",
       "      <td>广州创信网络科技有限公司</td>\n",
       "      <td>大专</td>\n",
       "      <td>1年经验</td>\n",
       "      <td>广州创信网络科技有限公司成立于2018年，集软件研发、AI智能为一体的信息技术解决服务提供商...</td>\n",
       "      <td>招若干人</td>\n",
       "      <td>计算机软件</td>\n",
       "      <td>50-150人</td>\n",
       "      <td>NaN</td>\n",
       "      <td>2021-05-29</td>\n",
       "      <td>0.7-1万/月</td>\n",
       "      <td>数据分析</td>\n",
       "      <td>05-29发布</td>\n",
       "      <td>产品销售数据分析助理+双休</td>\n",
       "      <td>五险一金,员工旅游,年终奖金,绩效奖金,定期体检,弹性工作,周末双休</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>扬州-邗江区</td>\n",
       "      <td>民营公司</td>\n",
       "      <td>扬州亿和帽业有限公司</td>\n",
       "      <td>本科</td>\n",
       "      <td>2年经验</td>\n",
       "      <td>我们围绕帽子构建起一流的设计、营销能力，并已将产品拓展到手套、围巾等时尚服饰。通过遍...</td>\n",
       "      <td>招1人</td>\n",
       "      <td>互联网/电子商务,服装/纺织/皮革</td>\n",
       "      <td>50-150人</td>\n",
       "      <td>岗位职责：,1、负责定期对公司经营数据进行整理和分析；,2、制作相关报表，并形成日、周、月数...</td>\n",
       "      <td>2021-05-29</td>\n",
       "      <td>3-6千/月</td>\n",
       "      <td>数据分析</td>\n",
       "      <td>05-29发布</td>\n",
       "      <td>数据分析专员</td>\n",
       "      <td>周休一天半,节日福利,绩效奖金,餐饮补贴,员工旅游,出国机会</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>广州-番禺区</td>\n",
       "      <td>民营公司</td>\n",
       "      <td>比欧(深圳)贸易有限公司广州分公司</td>\n",
       "      <td>大专</td>\n",
       "      <td>2年经验</td>\n",
       "      <td>一、公司简介,比欧(深圳)贸易有限公司成立于2013年，位于广州市番禺区大石礼村南路5号，是...</td>\n",
       "      <td>招2人</td>\n",
       "      <td>服装/纺织/皮革,贸易/进出口</td>\n",
       "      <td>150-500人</td>\n",
       "      <td>1、负责电商平台运营数据的分析工作，针对数据要求提取、汇总数据，提供分析报告及优化建议；,2...</td>\n",
       "      <td>2021-05-29</td>\n",
       "      <td>0.8-1万/月</td>\n",
       "      <td>数据分析</td>\n",
       "      <td>05-29发布</td>\n",
       "      <td>商品数据分析师</td>\n",
       "      <td>全勤奖,节日福利,下午茶,专业培训,员工旅游</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>...</th>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>167665</th>\n",
       "      <td>北京-海淀区</td>\n",
       "      <td>民营公司</td>\n",
       "      <td>上海索道投资管理有限公司</td>\n",
       "      <td>硕士</td>\n",
       "      <td>在校生/应届生</td>\n",
       "      <td>上海索道投资管理有限公司成立于 2016 年，是国内极少数专注于投资智能机器 人（服务机器人...</td>\n",
       "      <td>招1人</td>\n",
       "      <td>金融/投资/证券</td>\n",
       "      <td>少于50人</td>\n",
       "      <td>NaN</td>\n",
       "      <td>2021-05-29</td>\n",
       "      <td>2-4千/月</td>\n",
       "      <td>人工智能</td>\n",
       "      <td>05-11发布</td>\n",
       "      <td>行业研究员（实习岗）</td>\n",
       "      <td>NaN</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>167666</th>\n",
       "      <td>惠州-惠城区</td>\n",
       "      <td>民营公司</td>\n",
       "      <td>广州吾能学网络科技有限公司</td>\n",
       "      <td>大专</td>\n",
       "      <td>在校生/应届生</td>\n",
       "      <td>iLearn国际素质教育于2016年由中山大学管理学院EMBA校友会组织成立。,  ...</td>\n",
       "      <td>招20人</td>\n",
       "      <td>教育/培训/院校</td>\n",
       "      <td>50-150人</td>\n",
       "      <td>！！！实习科学教师可选趣味科学、人工智能、纯编程方向,岗位职责：,1、负责到合作学校开展小学...</td>\n",
       "      <td>2021-05-29</td>\n",
       "      <td>90元/天</td>\n",
       "      <td>人工智能</td>\n",
       "      <td>04-27发布</td>\n",
       "      <td>实习科学老师</td>\n",
       "      <td>专业培训,交通补贴,弹性工作</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>167667</th>\n",
       "      <td>苏州-工业园区</td>\n",
       "      <td>民营公司</td>\n",
       "      <td>上海索道投资管理有限公司</td>\n",
       "      <td>硕士</td>\n",
       "      <td>在校生/应届生</td>\n",
       "      <td>上海索道投资管理有限公司成立于 2016 年，是国内极少数专注于投资智能机器 人（服务机器人...</td>\n",
       "      <td>招1人</td>\n",
       "      <td>金融/投资/证券</td>\n",
       "      <td>少于50人</td>\n",
       "      <td>NaN</td>\n",
       "      <td>2021-05-29</td>\n",
       "      <td>2-3千/月</td>\n",
       "      <td>人工智能</td>\n",
       "      <td>05-01发布</td>\n",
       "      <td>行业研究员（实习岗）</td>\n",
       "      <td>NaN</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>167668</th>\n",
       "      <td>上海-普陀区</td>\n",
       "      <td>民营公司</td>\n",
       "      <td>上海方立数码科技有限公司</td>\n",
       "      <td>大专</td>\n",
       "      <td>在校生/应届生</td>\n",
       "      <td>上海方立数码科技有限公司，2002 年成立，注册于张江普陀机器人产业园。公司致力于人工...</td>\n",
       "      <td>招5人</td>\n",
       "      <td>计算机软件</td>\n",
       "      <td>150-500人</td>\n",
       "      <td>岗位描述：,1、参与软件产品（智能机器人、指纹、人脸识别产品）项目研发工作；,2、根据开发进...</td>\n",
       "      <td>2021-05-29</td>\n",
       "      <td>4.5-6千/月</td>\n",
       "      <td>人工智能</td>\n",
       "      <td>04-01发布</td>\n",
       "      <td>C++/QT开发工程师（机器人行业）</td>\n",
       "      <td>NaN</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>167669</th>\n",
       "      <td>上海</td>\n",
       "      <td>外资（非欧美）</td>\n",
       "      <td>紫光展锐</td>\n",
       "      <td>本科</td>\n",
       "      <td>在校生/应届生</td>\n",
       "      <td>紫光展锐是我国集成电路设计产业的龙头企业，作为未来数字世界的生态承载者，以生态为核心战略，高...</td>\n",
       "      <td>03-31发布</td>\n",
       "      <td>电子技术/半导体/集成电路</td>\n",
       "      <td>1000-5000人</td>\n",
       "      <td>1. 按照项目要求负责展锐芯片硬件平台方案制定、评估、器件选型、原理图设计、PCB布线的检查...</td>\n",
       "      <td>2021-05-29</td>\n",
       "      <td>3.5-7千/月</td>\n",
       "      <td>人工智能</td>\n",
       "      <td>NaN</td>\n",
       "      <td>硬件工程师实习生4333 (职位编号：004333)</td>\n",
       "      <td>弹性工作,免费班车,餐饮补贴,专业培训</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "<p>167670 rows × 16 columns</p>\n",
       "</div>"
      ],
      "text/plain": [
       "        address attribute            company education experience  \\\n",
       "0        重庆-江北区      上市公司  平安普惠企业管理有限公司重庆分公司        本科       1年经验   \n",
       "1        上海-青浦区      民营公司         上海裕络物流有限公司        本科     3-4年经验   \n",
       "2        广州-白云区      民营公司       广州创信网络科技有限公司        大专       1年经验   \n",
       "3        扬州-邗江区      民营公司         扬州亿和帽业有限公司        本科       2年经验   \n",
       "4        广州-番禺区      民营公司  比欧(深圳)贸易有限公司广州分公司        大专       2年经验   \n",
       "...         ...       ...                ...       ...        ...   \n",
       "167665   北京-海淀区      民营公司       上海索道投资管理有限公司        硕士    在校生/应届生   \n",
       "167666   惠州-惠城区      民营公司      广州吾能学网络科技有限公司        大专    在校生/应届生   \n",
       "167667  苏州-工业园区      民营公司       上海索道投资管理有限公司        硕士    在校生/应届生   \n",
       "167668   上海-普陀区      民营公司       上海方立数码科技有限公司        大专    在校生/应届生   \n",
       "167669       上海   外资（非欧美）               紫光展锐        本科    在校生/应届生   \n",
       "\n",
       "                                        general_situation hiring_num  \\\n",
       "0       平安普惠业务集群（以下简称“平安普惠”）是中国平安保险（集团）股份有限公司联营公司旗下成员，...        招1人   \n",
       "1       公司介绍,裕络物流于2008年创立上海，主要从事国内第三方物流业务包括行业物流解决方案、多式...        招1人   \n",
       "2       广州创信网络科技有限公司成立于2018年，集软件研发、AI智能为一体的信息技术解决服务提供商...       招若干人   \n",
       "3           我们围绕帽子构建起一流的设计、营销能力，并已将产品拓展到手套、围巾等时尚服饰。通过遍...        招1人   \n",
       "4       一、公司简介,比欧(深圳)贸易有限公司成立于2013年，位于广州市番禺区大石礼村南路5号，是...        招2人   \n",
       "...                                                   ...        ...   \n",
       "167665  上海索道投资管理有限公司成立于 2016 年，是国内极少数专注于投资智能机器 人（服务机器人...        招1人   \n",
       "167666      iLearn国际素质教育于2016年由中山大学管理学院EMBA校友会组织成立。,  ...       招20人   \n",
       "167667  上海索道投资管理有限公司成立于 2016 年，是国内极少数专注于投资智能机器 人（服务机器人...        招1人   \n",
       "167668     上海方立数码科技有限公司，2002 年成立，注册于张江普陀机器人产业园。公司致力于人工...        招5人   \n",
       "167669  紫光展锐是我国集成电路设计产业的龙头企业，作为未来数字世界的生态承载者，以生态为核心战略，高...    03-31发布   \n",
       "\n",
       "                 industry     members  \\\n",
       "0             金融/投资/证券,银行  1000-5000人   \n",
       "1                交通/运输/物流    150-500人   \n",
       "2                   计算机软件     50-150人   \n",
       "3       互联网/电子商务,服装/纺织/皮革     50-150人   \n",
       "4         服装/纺织/皮革,贸易/进出口    150-500人   \n",
       "...                   ...         ...   \n",
       "167665           金融/投资/证券       少于50人   \n",
       "167666           教育/培训/院校     50-150人   \n",
       "167667           金融/投资/证券       少于50人   \n",
       "167668              计算机软件    150-500人   \n",
       "167669      电子技术/半导体/集成电路  1000-5000人   \n",
       "\n",
       "                                                 position record_date  \\\n",
       "0                                                     NaN  2021-05-29   \n",
       "1                                                     NaN  2021-05-29   \n",
       "2                                                     NaN  2021-05-29   \n",
       "3       岗位职责：,1、负责定期对公司经营数据进行整理和分析；,2、制作相关报表，并形成日、周、月数...  2021-05-29   \n",
       "4       1、负责电商平台运营数据的分析工作，针对数据要求提取、汇总数据，提供分析报告及优化建议；,2...  2021-05-29   \n",
       "...                                                   ...         ...   \n",
       "167665                                                NaN  2021-05-29   \n",
       "167666  ！！！实习科学教师可选趣味科学、人工智能、纯编程方向,岗位职责：,1、负责到合作学校开展小学...  2021-05-29   \n",
       "167667                                                NaN  2021-05-29   \n",
       "167668  岗位描述：,1、参与软件产品（智能机器人、指纹、人脸识别产品）项目研发工作；,2、根据开发进...  2021-05-29   \n",
       "167669  1. 按照项目要求负责展锐芯片硬件平台方案制定、评估、器件选型、原理图设计、PCB布线的检查...  2021-05-29   \n",
       "\n",
       "            salary   tag     time                       title  \\\n",
       "0           6-8千/月  数据分析  05-28发布  1734LO-数据分析岗 (职位编号：1734LO)   \n",
       "1       0.8-1.5万/月  数据分析  05-29发布                 运营质量及数据分析经理   \n",
       "2         0.7-1万/月  数据分析  05-29发布               产品销售数据分析助理+双休   \n",
       "3           3-6千/月  数据分析  05-29发布                      数据分析专员   \n",
       "4         0.8-1万/月  数据分析  05-29发布                     商品数据分析师   \n",
       "...            ...   ...      ...                         ...   \n",
       "167665      2-4千/月  人工智能  05-11发布                  行业研究员（实习岗）   \n",
       "167666       90元/天  人工智能  04-27发布                      实习科学老师   \n",
       "167667      2-3千/月  人工智能  05-01发布                  行业研究员（实习岗）   \n",
       "167668    4.5-6千/月  人工智能  04-01发布          C++/QT开发工程师（机器人行业）   \n",
       "167669    3.5-7千/月  人工智能      NaN  硬件工程师实习生4333 (职位编号：004333)   \n",
       "\n",
       "                                   welfare  \n",
       "0                           五险一金,年底双薪,定期体检  \n",
       "1                      五险一金,年终奖金,通讯补贴,餐饮补贴  \n",
       "2       五险一金,员工旅游,年终奖金,绩效奖金,定期体检,弹性工作,周末双休  \n",
       "3           周休一天半,节日福利,绩效奖金,餐饮补贴,员工旅游,出国机会  \n",
       "4                   全勤奖,节日福利,下午茶,专业培训,员工旅游  \n",
       "...                                    ...  \n",
       "167665                                 NaN  \n",
       "167666                      专业培训,交通补贴,弹性工作  \n",
       "167667                                 NaN  \n",
       "167668                                 NaN  \n",
       "167669                 弹性工作,免费班车,餐饮补贴,专业培训  \n",
       "\n",
       "[167670 rows x 16 columns]"
      ]
     },
     "execution_count": 2,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "job=pd.read_csv('job.csv',encoding='utf-8')\n",
    "job"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "metadata": {},
   "outputs": [],
   "source": [
    "# job_1 = job.query('tag==\"算法\"')\n",
    "# job_1.shape"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "metadata": {},
   "outputs": [],
   "source": [
    "# job_1['position'].isnull().sum()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 5,
   "metadata": {},
   "outputs": [],
   "source": [
    "# position = job_1['position'].dropna()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 6,
   "metadata": {},
   "outputs": [],
   "source": [
    "# position"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 7,
   "metadata": {},
   "outputs": [],
   "source": [
    "import os\n",
    " \n",
    " #读取news_data.csv，保存到新建的news_data.txt中\n",
    "data = pd.read_csv('job.csv', encoding='utf-8')\n",
    "with open('job.txt','a+', encoding='utf-8') as f:\n",
    "    for line in data.values:\n",
    "        #str(line[0])：csv中第0列；+','+：csv两列之间保存到txt用逗号（，）隔开；'\\n'：读取csv每行后在txt中换行\n",
    "        f.write((str(line[9])+'\\n'))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "Building prefix dict from the default dictionary ...\n",
      "Dumping model to file cache C:\\Users\\ADMINI~1\\AppData\\Local\\Temp\\jieba.cache\n",
      "Loading model cost 1.062 seconds.\n",
      "Prefix dict has been built successfully.\n"
     ]
    }
   ],
   "source": [
    "def chinese_word_cloud_with_stop_words():\n",
    "    # 词云文本的路径\n",
    "    path = \"./job.txt\"\n",
    " \n",
    "    # 过滤词云文本的路径\n",
    "#     path_sw = \"Chinese_Stopwords.txt\"\n",
    " \n",
    "    # 打开词云文件读取\n",
    "    with open('./job.txt', 'r', encoding=\"utf-8\") as f:\n",
    "        cut_text = f.read()\n",
    "        pass\n",
    " \n",
    "    # 打开过滤词云文件读取\n",
    "#     with open(path_sw, 'r', encoding=\"utf-8\") as f:\n",
    "#         stop_words_text = f.read()\n",
    "#         pass\n",
    " \n",
    "    # 打印读取结果\n",
    "    # print(cut_text)\n",
    "    # print(stop_words_text)\n",
    " \n",
    "    # jieba 分词\n",
    "    jieba_str = jieba.cut(cut_text)\n",
    "#     jieba_stop_words_str = jieba.cut(stop_words_text)\n",
    "    # print(jieba_str)\n",
    "    # print(jieba_stop_words_str)\n",
    "    cut_text = \" \".join(jieba_str)\n",
    "#     stop_words_text = \" \".join(jieba_stop_words_str)\n",
    "    # print(cut_text)\n",
    "    # print(stop_words_text)\n",
    " \n",
    "    # 配置词云图，并生成词云图\n",
    "    word_cloud = WordCloud(\n",
    "        # 注意字体设置（win 自带字体库，选择自己需要的字体即可）\n",
    "        font_path=\"C:/Windows/Fonts/simfang.ttf\",\n",
    "        background_color=\"white\",\n",
    "        width=1920,\n",
    "        height=1080,\n",
    "        # 过滤词云设置\n",
    "#         stopwords=stop_words_text\n",
    "    ).generate(cut_text)\n",
    " \n",
    "    # 显示词云图\n",
    "    plt.imshow(word_cloud, interpolation=\"bilinear\")\n",
    "    plt.axis('off')\n",
    "    plt.show()\n",
    " \n",
    "    # 保存词云图\n",
    "#     word_cloud.to_file(\"./chinese_word_cloud_with_stop_words.png\")\n",
    "#     pass\n",
    " \n",
    " \n",
    "def main():\n",
    "    chinese_word_cloud_with_stop_words()\n",
    "    pass\n",
    " \n",
    " \n",
    "if __name__ == '__main__':\n",
    "    main()\n",
    "    pass"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.8.5"
  },
  "toc": {
   "base_numbering": 1,
   "nav_menu": {},
   "number_sections": true,
   "sideBar": true,
   "skip_h1_title": false,
   "title_cell": "Table of Contents",
   "title_sidebar": "Contents",
   "toc_cell": false,
   "toc_position": {},
   "toc_section_display": true,
   "toc_window_display": false
  }
 },
 "nbformat": 4,
 "nbformat_minor": 4
}
